package com.sugon.modules.device.model.vo;

import com.sugon.entity.DevMaintenancePlanItemEntity;
import com.sugon.modules.device.consts.DevMaintenancePlanFreType;
import lombok.Data;

import java.util.Date;
import java.util.List;

/**
 * @author ： YuXD
 * @description： 设备维护计划明细详情VO，包含设备维护项详情
 * @date ： 2020-08-12 16:10
 * @version: 1.0
 */
@Data
public class DevMaintenancePlanItemDetailVO extends DevMaintenancePlanItemEntity {

    /**
     * 车间ID
     */
    private String workshop;
    /**
     * 人次
     */
    private Integer perEv;
    /**
     * 选项备注
     */
    private String remark;
    /**
     * 选项类型
     */
    private String type;
    /**
     * 选项名称
     */
    private String name;
    /**
     * 检查时间
     */
    private Integer checkType;
    /**
     * 检查标准 内容
     */
    private String checkSt;
    /**
     * 检查方法-测量方法2020.4.9
     */
    private String methodType;
    /**
     * 检测工具 2020.4.9
     */
    private String checkTool;
    /**
     * 设备状态 2020.4.9
     */
    private Integer devStatus;

    private String devStatusDesc;

    public String getDevStatusDesc() {
        String devStatusDesc = "未知";
        // 非空处理
        if (this.devStatus == null) {
            if (this.checkDatePrud != null) {
                this.devStatus = 1;
            } else if (this.checkDateUprud != null) {
                this.devStatus = 0;
            }
        }
        if (this.devStatus == 1) {
            devStatusDesc = "运行";
        } else if (this.devStatus == 0) {
            devStatusDesc = "停机";
        }
        return devStatusDesc;
    }

    /**
     * 属性 1 S:安全 2 E:环保 3 C:委外
     */
    private Integer attribute;

    /**
     * 1:'预测性',2:'预防性'
     */
    private Integer mainType;
    /**
     * 生产时间
     */
    private Integer checkDatePrud;
    /**
     * 非生产时间
     */
    private Integer checkDateUprud;
    /**
     * 实施频率 1每周 2.每两周 3.每月 4.每两月 5.每季 6.每半年 7.一年
     */
    private Integer freRate;

    private String freRateDesc;

    /**
     * 周次
     */
    private Integer weeksOfYear;

    /**
     * 年度
     */
    private Integer yearly;

    public String getFreRateDesc() {
        String freRateDesc = "";
        if (this.freRate != null) {
            switch (this.freRate) {
                case DevMaintenancePlanFreType.WEEKLY:
                    freRateDesc = "每周";
                    break;
                case DevMaintenancePlanFreType.FORTNIGHT:
                    freRateDesc = "每两周";
                    break;
                case DevMaintenancePlanFreType.MONTH:
                    freRateDesc = "每月";
                    break;
                case DevMaintenancePlanFreType.QUARTER:
                    freRateDesc = "每季";
                    break;
                case DevMaintenancePlanFreType.HALF_YEAR:
                    freRateDesc = "每半年";
                    break;
                case DevMaintenancePlanFreType.YEAR:
                    freRateDesc = "每年";
                    break;
                default:
            }
        }
        return freRateDesc;
    }

    /************关联查询获取以下数据**************/

    private Date startDate;

    private Date endDate;

    private String devCode;

    private String line;

    private String process;

    private String devName;

    /**
     * 实施状态 1:已实施 0:未实施
     */
    private Integer implementStatus;

    /**
     * 计划明细项实施列表
     */
    private List<DevMaintenancePlanItemImplementDetailDTO> implementDetailList;

    /**
     * 获取设备维护间隔天数
     *
     * @return
     */
    public int getDevMaintenanceIntervalDays() {
        int days = 0;
        switch (this.freRate) {
            case DevMaintenancePlanFreType.WEEKLY:
                days = 7;
                break;
            case DevMaintenancePlanFreType.FORTNIGHT:
                days = 14;
                break;
            case DevMaintenancePlanFreType.MONTH:
                days = 30;
                break;
            case DevMaintenancePlanFreType.QUARTER:
                days = 90;
                break;
            case DevMaintenancePlanFreType.HALF_YEAR:
                days = 183;
                break;
            case DevMaintenancePlanFreType.YEAR:
                days = 365;
                break;
            default:
        }
        return days;
    }

    public Integer getCheckDatePrud() {
        return checkDatePrud == null ? 0 : checkDatePrud;
    }

    public Integer getCheckDateUprud() {
        return checkDateUprud == null ? 0 : checkDateUprud;
    }

    public Integer getPerEv() {
        return perEv == null ? 1 : perEv;
    }
}
